<%--
  Created by IntelliJ IDEA.
  User: vevive
  Date: 2020/10/13
  Time: 19:48
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<html>
<head>
    <title>购物车</title>
    <!--引入外部样式文件-->
    <link rel="stylesheet" href="/css/bootstrap.min.css"/>

</head>
<head>
    <style>
        body {
            background-color: #abdde5;
        }
    </style>
</head>
<body>
<h1 align="center"><br/><br/>购物车
    <div>
        <p align="left">
            <a href="/index.jsp" class="btn btn-outline-success mx-5">◂</a>
        </p>
    </div>
</h1>
<c:choose>
    <c:when test="${fn:length(requestScope.carViewList)==0}">
        <br/><br/>
        <h2 align="center"><br/> <br/>您的购物车中暂无商品<a href="/index.jsp">去逛逛...</a></h2>
    </c:when>
    <c:otherwise>
        <table class="table table-hover">
            <thead>
            <tr>
                <th scope="col">序号</th>
                <th scope="col">花卉名</th>
                <th scope="col">单价</th>
                <th scope="col">购买数量</th>
                <th scope="col">图片</th>
                <th scope="col">合计</th>
                <th scope="col">操作</th>
            </tr>
            </thead>
            <tbody>
            <c:set var="total_price" value="0"/>
            <c:forEach items="${requestScope.carViewList}" var="carView" varStatus="status">
                <tr>
                    <th scope="row">${status.count}</th>
                    <td>${carView.flower_name}</td>
                    <td>${carView.flower_price}</td>

                    <td>${carView.car_count}</td>

                    <td><img src="/img/flower/${carView.flower_image}" style="width: 150px;height: 150px"/></td>
                    <td>
                            ${carView.sum_price}
                        <c:set var="total_price" value="${total_price+carView.sum_price}"/>
                    </td>

                </tr>
            </c:forEach>
            <tr>
                <td colspan="7">
                    <br/><br/>
                    <p align="right">
                        总价:${total_price}
                        <a href="/buy.jsp?total_price=${total_price}"
                           class="btn btn-outline-danger btn-lg mx-5">立即购买</a>
                    </p>
                </td>
            </tr>

            </tbody>
        </table>
        </p>
    </c:otherwise>
</c:choose>


<script src="/js/jquery-3.4.1.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
<script src="/js/popper.min.js"></script>
<script src="/layer-v3.1.1/layer/layer.js"></script>
</body>
</html>
